Release 10.1A: OpenEdge Development:
Programming Interfaces
Example HLC application
This section explains how to use the OpenEdge HLC tank demo application. This application is a prepackaged application that you can use to verify that your HLC environment is set up correctly. The C code and sample output for this example are provided in the
$DLC/oebuild/hlc/examplesdirectory on UNIX, and in the%DLC%\oebuild\hlc\examplesdirectory in Windows.Set up your environment and compile this example before you try to run it to verify that your compiler and the OEBuild utility are working correctly. This also helps you learn how to use HLC in a controlled environment.
This sample application uses OpenEdge to keep track of oil storage tanks. Your Progress procedure calls a C program,
AVCALC, to calculate the available capacity for a given tank. Figure 18–7 shows that the tanks are cylindrical, with their axes parallel to the level ground.Figure 18–7: Tank positioning and orientation
![]()
To calculate the available capacity (empty portion) of the tank, you need to know the tank’s diameter, length, and current level of oil. Use the variables in the following formula to calculate the available tank volume:
![]()
rRadius of the tank
lengthLength of the tank
levelLevel of oil in the tank
For this example, assume there is a tank table for this application that contains the following decimal fields:
radiusRadius of tank
tlengthLength of tank
depthLevel of oil—must be between 0 and (2 . radius)
tavailAvailable volume in tank
In addition to these fields, the tank-id character field is used as the primary index.
Figure 18–8 shows the Data Dictionary report for the tank table.
Figure 18–8: Data Dictionary report for tank application
A C function calculates the tavail field from the other three decimal fields (radius, tlength, depth). Figure 18–9 shows the Progress procedure that invokes the C function by calling the HLC routine,
AVCALC.
Figure 18–9: Progress procedure calling HLC routine AVCALC
Make a copy of the HLC dispatch routine,
hlprodsp.c, and name ittankdsp.c. Modify the routine so that an entry appears forAVCALC, which calls the C subroutinehlvcalc.Example
hlprodsp.cshows the modifications to thetankdsp.croutine:
The following procedure shows the code for the demo program,
hlvcalc.c. The program extracts the radius, length, and level fields from the shared buffer tank, calculates the available volume, and updates the tavail field in the shared buffer tank with the number calculated:
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |